import React from 'react';
import { Button } from 'antd';

import DataSet from '@antv/data-set';
import {Chart, Geom, Axis, Tooltip, Legend, Coord, Guide, Label,Shape} from 'bizcharts';
import styles from './index.less';
const { Arc, Html, Line } = Guide;
const data = [
    { month: 'Jan', member: 7.0, total: 3.9 },
    { month: 'Feb', member: 6.9, total: 4.2 },
    { month: 'Mar', member: 9.5, total: 5.7 },
    { month: 'Apr', member: 14.5, total: 8.5 },
    { month: 'May', member: 18.4, total: 11.9 },
    { month: 'Jun', member: 21.5, total: 15.2 },
    { month: 'Jul', member: 25.2, total: 17.0 },
    { month: 'Aug', member: 26.5, total: 16.6 },
    { month: 'Sep', member: 23.3, total: 14.2 },
    { month: 'Oct', member: 18.3, total: 10.3 },
    { month: 'Nov', member: 13.9, total: 6.6 },
    { month: 'Dec', member: 9.6, total: 4.8 }
];
const cols = {
    month: {
        range: [ 0, 1 ]
    }
}

export default ({ height}) => {

    const ds = new DataSet();
    const dv = ds.createView().source(data);
    dv.transform({
        type: 'fold',
        fields: [ 'member', 'total' ], // 展开字段集
        key: 'city', // key字段
        value: 'temperature', // value字段
    });
    console.log(dv);
  return (
      <Chart height={height} data={dv} scale={cols} padding={[15, 0, 40, 0]} forceFit>
          <Axis name="month" />
          <Axis name="temperature" label={null}/>
          <Legend position='top'/>
          <Tooltip crosshairs={{type : "y"}}/>
          <Geom type="line" position="month*temperature" size={2} color={'city'} />
          <Geom type='point' position="month*temperature" size={3} shape={'circle'} color={'city'} style={{ stroke: '#fff', lineWidth: 1}} />
      </Chart>
  );
};
